package com.twu.biblioteca.model;

import com.twu.biblioteca.model.LibraryItem;

public class Movie extends LibraryItem {
    private final String director;
    private final int rating;

    public Movie(String title, String director, String year, int rating) {
        super(title, year);
        this.director = director;
        this.rating = rating;
    }

    public String getDirector() {
        return director;
    }

    public int getRating() {
        return rating;
    }

    @Override
    public String toString() {
        String ratingString = getRatingString();
        return "Title: '" + this.getTitle() + "'" + LIST_SEPARATOR +
                "Director: '" + this.director + "'" + LIST_SEPARATOR +
                "Year: '" + this.getYearPublished() + "'" + LIST_SEPARATOR +
                "Rating: '" + ratingString + "'";

    }

    private String getRatingString() {
        String ratingString = "";
        if (rating > 0 && rating <= 10)
            ratingString += rating;
        else
            ratingString = "unrated";

        return ratingString;
    }

    @Override
    public boolean hasDetails(String... args) { //TODO do we need rating here?
        if (args == null) return false;
        if (!(args.length == 3)) return false;
        if (!args[0].equalsIgnoreCase(getTitle())) return false;
        if (!args[1].equalsIgnoreCase(getDirector())) return false;
        if (!args[2].equalsIgnoreCase(getYearPublished())) return false;
        return true;
    }
}

